1. Field of the Invention
The present invention relates to an image processing apparatus and an image processing method, which execute drawing processing of three-dimensional (3D) computer graphics, and a computer program product for image processing.
2. Description of the Related Art
In the drawing processing of the 3D computer graphics, if plural drawn objects overlap when viewed from a viewpoint, Z values, which are coordinate values in a depth direction of respective pixels, are compared, and a drawn object located closest to the viewer is drawn whereas a drawn object located at a deeper point than the former object is eliminated. This processing is called “hidden-surface removal”.
For the hidden-surface removal, a Z-buffer which stores Z values of pixels of one frame must be provided, and Z values of newly drawn object must be compared with the stored Z value in the Z-buffer. The data of the Z-buffer is usually placed in a memory such as a Dynamic Random Access Memory (DRAM) with a low access rate, making the memory access for the writing/reading of the data of the Z-buffer a bottleneck in the processing of 3D computer graphics drawing. An access frequency to the Z-buffer therefore significantly affects the overall performance of the 3D computer graphics processing apparatus.
One conventionally proposed method to improve the performance through reduced access frequency to the Z-buffer divides a drawing area into rectangular areas called blocks, and employs a hierarchical Z-buffer which stores a Z value of a deepest pixel among pixels in the block, thereby achieving the hidden-surface removal on block-to-block basis prior to the hidden-surface removal on pixel-to-pixel basis.
According to the proposed method, when a drawn object is a polygon occupying some pixels in a block, a Z value of a pixel which is closest to the viewer is found as a Znear value. Then, the Znear value is compared with a Z value of a deepest pixel of a previously drawn polygon(s) in the pertinent block stored in the hierarchical Z-buffer. If the pixel of the Znear value is located deeper than the pixel of the corresponding Z value stored in the hierarchical Z-buffer, drawing of the pixels of the newly-drawn polygon in the pertinent block is eliminated altogether. Then, the frequency of memory access can be reduced compared with the pixel-based hidden surface removal, to enhance the processing performance.
If the calculation of the Znear value takes time, however, performance may be deteriorated, nullifying the introduction of block-based hidden surface removal. Hence, the high-speed calculation of the Znear value is imperative. However, for the precise calculation of the Znear value, the intersection between the block area and the polygon area needs to be identified. Such processing requires a significantly high computational cost, and might hinder the high-speed calculation of the Znear value.
Hence, a Z value of a pixel closer to the viewer than the pixel of the precise Znear value may be utilized for the hidden-surface removal. Such a Z value can be more easily and speedily found than the precise Znear value.
When the Z value of the pixel located closer to the viewer than the pixel of the precise Znear value is employed for the hidden-surface removal, since the actual pixels of the polygon are surely located deeper than the pixel corresponding to this Z value, a pixel which is supposed to be in front of the previously-drawn polygon is not eliminated. Further, the precision of hidden-surface removal can be maintained at a high level if the Z value is highly approximate to the precise Znear value.
For example, U.S. Pat. No. 6,646,639 (hereinafter also referred to as Patent Literature 1) discloses a method to use a Z value of a closest pixel on a plane of the newly drawn polygon in the block area (block Z value) instead of the Znear value. According to Patent Literature 1, the closest pixel is selected from pixels at four corners of the block based on the information on the inclination of the plane formed by the newly-drawn polygon. Thus, since the identification of the intersection between the polygon area and the block area is not necessary, the high-speed hidden-surface removal is allowed.
According to the technique of the Patent Literature 1, however, when the pixel selected from the four corners of the block is located outside the area occupied by the polygon, the difference between the block Z value and the Znear value becomes notable, and the efficient hidden-surface removal may be hindered.
If the polygon of the data is large and the pixels selected from the four corners of the block are highly likely to be located in the polygon area, negative effect to the performance efficiency will be ignorable. In recent years, however, the resolution of the image dealt with in the 3D computer graphics is increasing, whereby in the drawing the polygon is likely to be smaller and the pixels selected from the four corners of the block are highly likely to be located outside the polygon area. Then, the efficient hidden-surface removal is difficult to be guaranteed.